<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/css/merchant.css" />

<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
{$jsFile}
<title>社区一卡通_商户登录</title>
</head>
<body>
<div style="padding:0;width:960px; margin:0 auto;">
	<div><img style="float:left;" src="/images/shanghu_login_img.jpg" />
	<div style="float:right; margin-right: 20px;">        		
			<div style="margin:80px 0 20px 0;">
				<img src="/images/shanghu_login_title.jpg" />
			</div>
			<div>
				<input type="text" placeholder="账户" onkeydown="check(event)" id="txt_username" class="input_c input_login" value="" name="txt_username" />
			</div>
			<div>
				{if $isIE eq 1}
				<input type="text" placeholder="密码" id="txt_password1" class="input_c input_login" name="txt_password1" />
				<input type="password" style="display:none;" placeholder="密码" id="txt_password" class="input_c input_login" name="txt_password" />
				{else}
				<input type="password" onkeydown="check(event)" placeholder="密码" id="txt_password" class="input_c input_login" name="txt_password" />
				{/if}
			</div>
			<div style="display:block;">
				<input type="text" onkeydown="check(event)" style="width:100px; float:left;" placeholder="验证码" id="txt_checkcode" class="input_c input_login" name="txt_checkcode" />
				<img onclick="reload()" id="codepic" src="/merchant/account/code" width="95" height="27" style="margin-left:5px;" alt="vcode" />
			</div>
			<div class="sub_log clearfix" style="margin-top:30px;">
				<div class="sub_login">
					<input type="button" onclick="check()" class="no_bg" style="width:97px; height:35px; font-size:20px;" />
				</div>
				
			</div>
			<div class="clear"></div>
			<div class="login_error">
				<div id="msg">
					{$msg}
				</div>
			</div>
	</div>
	</div>
	<div class="clear"></div>
</div>
{include file="common/s_foot.tpl"}

{literal}
<script type="text/javascript">	

function reload(){
	var cpt = document.getElementById('codepic');
	cpt.src	= '/merchant/account/code/?t='+Math.random();
}

function showError(msg)
{
	$('#msg').show();
	$('#msg').html(msg);
}
function check(){
	if(arguments.length==1)
	{
		var keys=arguments[0];
		if(keys.keyCode!=13)
		{
			return false;
		}
	}
	
	var username = $('#txt_username').val();
	var password = $('#txt_password').val();
	var checkcode = $('#txt_checkcode').val();
	var cstr = '/\w+/';
	if(username==''){
		showError('用户名不能为空！');
		return false;
	}
	else if(password==''){
		showError('密码不能为空！');
		return false;
	}
	else if(checkcode==''){
		showError('验证码不能为空！');
		return false;
	}

    $.ajax({  
        type : "post",  
        url : "/merchant/account/userLogin",  
        data : { txt_checkcode: checkcode,user_name:username,pwd:password},  
        async : false,
        success : function(data){  
        	if(data == -1){
        		showError('验证码错误！');
    			reload();
    		}
        	else if(data == -2){
        		showError('用户名或密码错误！');
    			return false;
        	}
        	else if(data == 1){
        		window.location.href="/merchant/index/first_login";
        	}
        	else if(data==2)
        	{
        		window.location.href="/merchant/index/show";
        	}
        }  
    });  
}


</script>
{/literal}
{$jsBlock}
</body>
</html>